package hacker_rank;

import java.util.Arrays;
import java.util.Scanner;

public class MarkAndToys {
	
	public void solve(int[] toys, int k)
	{
		Arrays.sort(toys);
		
		int res = 0;
		for(int i = 0; i < toys.length; i++) {
			if(toys[i] <= k) {
				res++;
				k -= toys[i]; 
			} else
				break;
		}
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int k = in.nextInt();
		
		int[] toys = new int[n];
		
		for(int i = 0; i < n; i++) {
			toys[i] = in.nextInt();
		}
		
		MarkAndToys mat = new MarkAndToys();
		mat.solve(toys, k);
	}

}
